bitkeeper revision 1.1159.80.1 (414f0be4vQDZaLNox7YheSOsmEXZFw)
authormwilli2@equilibrium.research <mwilli2@equilibrium.research>
Mon, 20 Sep 2004 16:57:08 +0000 (16:57 +0000)
committermwilli2@equilibrium.research <mwilli2@equilibrium.research>
Mon, 20 Sep 2004 16:57:08 +0000 (16:57 +0000)
Clean up terminology in comments and fix xentrace for new memory
mapping interface.

tools/xentrace/xentrace.c
xen/common/trace.c
xen/include/hypervisor-ifs/dom0_ops.h
xen/include/hypervisor-ifs/trace.h

index 9972422878d740124040f6ab0dcc6dbfc713220e..970e0d171b2d1e1fcf1491b3acfdb7927a259adf 100644 (file)
@@ -85,13 +85,13 @@ void write_rec(unsigned int cpu, struct t_rec *rec, FILE *out)
 
 /**
  * get_tbufs - get pointer to and size of the trace buffers
- * @phys_addr: location to store physical address if the trace buffers to
+ * @mach_addr: location to store machine address if the trace buffers to
  * @size:      location to store the size of a trace buffer to
  *
- * Gets the physical address of the trace pointer area and the size of the
+ * Gets the machine address of the trace pointer area and the size of the
  * per CPU buffers.
  */
-void get_tbufs(unsigned long *phys_addr, unsigned long *size)
+void get_tbufs(unsigned long *mach_addr, unsigned long *size)
 {
     int ret;
     dom0_op_t op;                        /* dom0 op we'll build             */
@@ -110,40 +110,40 @@ void get_tbufs(unsigned long *phys_addr, unsigned long *size)
         exit(EXIT_FAILURE);
     }
 
-    *phys_addr = op.u.gettbufs.phys_addr;
+    *mach_addr = op.u.gettbufs.mach_addr;
     *size      = op.u.gettbufs.size;
 }
 
 /**
  * map_tbufs - memory map Xen trace buffers into user space
- * @tbufs:     physical address of the trace buffers
+ * @tbufs:     machine address of the trace buffers
  * @num:       number of trace buffers to map
  * @size:      size of each trace buffer
  *
  * Maps the Xen trace buffers them into process address space by memory mapping
  * /dev/mem.  Returns the location the buffers have been mapped to.
  */
-struct t_buf *map_tbufs(unsigned long tbufs_phys, unsigned int num,
+struct t_buf *map_tbufs(unsigned long tbufs_mach, unsigned int num,
                         unsigned long size)
 {
-    int dm_fd;                               /* file descriptor for /dev/mem */
+    int xc_handle;                  /* file descriptor for /proc/xen/privcmd */
     struct t_buf *tbufs_mapped;
 
-    dm_fd = open("/dev/mem", O_RDONLY);
+    xc_handle = xc_interface_open();
 
-    if ( dm_fd < 0 ) 
+    if ( xc_handle < 0 ) 
     {
-        PERROR("Open /dev/mem when mapping trace buffers\n");
+        PERROR("Open /proc/xen/privcmd when mapping trace buffers\n");
         exit(EXIT_FAILURE);
     }
 
-    tbufs_mapped = (struct t_buf *)mmap(NULL, size * num,
-                                        PROT_READ, MAP_SHARED,
-                                        dm_fd, (off_t)tbufs_phys);
+    tbufs_mapped = xc_map_foreign_range(xc_handle, 0 /* Dom 0 ID */,
+                                       size * num, PROT_READ,
+                                       tbufs_mach >> PAGE_SHIFT);
 
-    close(dm_fd);
+    xc_interface_close(xc_handle);
 
-    if ( tbufs_mapped == MAP_FAILED ) 
+    if ( tbufs_mapped == 0 ) 
     {
         PERROR("Failed to mmap trace buffers");
         exit(EXIT_FAILURE);
@@ -187,16 +187,16 @@ struct t_buf **init_bufs_ptrs(void *bufs_mapped, unsigned int num,
 
 /**
  * init_rec_ptrs - initialises data area pointers to locations in user space
- * @tbufs_phys:    physical base address of the trace buffer area
+ * @tbufs_mach:    machine base address of the trace buffer area
  * @tbufs_mapped:  user virtual address of base of trace buffer area
  * @meta:          array of user-space pointers to struct t_buf's of metadata
  * @num:           number of trace buffers
  *
  * Initialises data area pointers to the locations that data areas have been
- * mapped in user space.  Note that the trace buffer metadata contains physical
+ * mapped in user space.  Note that the trace buffer metadata contains machine
  * pointers - the array returned allows more convenient access to them.
  */
-struct t_rec **init_rec_ptrs(unsigned long tbufs_phys,
+struct t_rec **init_rec_ptrs(unsigned long tbufs_mach,
                              struct t_buf *tbufs_mapped,
                              struct t_buf **meta,
                              unsigned int num)
@@ -212,8 +212,8 @@ struct t_rec **init_rec_ptrs(unsigned long tbufs_phys,
     }
 
     for ( i = 0; i<num; i++ )
-        data[i] = (struct t_rec *)((unsigned long)meta[i]->data -
-                                   tbufs_phys + (unsigned long)tbufs_mapped);
+        data[i] = (struct t_rec *)(meta[i]->data - tbufs_mach
+                                  + (unsigned long)tbufs_mapped);
 
     return data;
 }
@@ -283,7 +283,7 @@ int monitor_tbufs(FILE *logfile)
     struct t_rec **data;         /* pointers to the trace buffer data areas
                                   * where they are mapped into user space.   */
     unsigned long *cons;         /* store tail indexes for the trace buffers */
-    unsigned long tbufs_phys;    /* physical address of the tbufs            */
+    unsigned long tbufs_mach;    /* machine address of the tbufs             */
     unsigned int  num;           /* number of trace buffers / logical CPUS   */
     unsigned long size;          /* size of a single trace buffer            */
 
@@ -293,36 +293,26 @@ int monitor_tbufs(FILE *logfile)
     num = get_num_cpus();
 
     /* setup access to trace buffers */
-    get_tbufs(&tbufs_phys, &size);
-    tbufs_mapped = map_tbufs(tbufs_phys, num, size);
+    get_tbufs(&tbufs_mach, &size);
+    tbufs_mapped = map_tbufs(tbufs_mach, num, size);
 
     size_in_recs = (size / sizeof(struct t_rec) )-1;
 
     /* build arrays of convenience ptrs */
     meta  = init_bufs_ptrs (tbufs_mapped, num, size);
-    data  = init_rec_ptrs  (tbufs_phys, tbufs_mapped, meta, num);
+    data  = init_rec_ptrs  (tbufs_mach, tbufs_mapped, meta, num);
     cons  = init_tail_idxs (meta, num);
 
     /* now, scan buffers for events */
     while ( !interrupted )
     {
         for ( i = 0; ( i < num ) && !interrupted; i++ )
-        {          
-/*         printf("XX%d: cons=%ld head=%ld  %p\n", i,
-                  cons[i], meta[i]->head, data[i] + (cons[i] % size_in_recs) );
-                  */
            while( cons[i] != meta[i]->head )
            {
-/*
-               if( (cons[i] % 6  ) == 0 )
-                   printf("%d: cons=%ld head=%ld  %p\n", i,
-                      cons[i], meta[i]->head, data[i] + (cons[i] % size_in_recs) );
-                      */
                write_rec(i, data[i] + (cons[i] % size_in_recs), logfile);
                cons[i]++;
            }
 
-        }
         nanosleep(&opts.poll_sleep, NULL);
     }
 
index f7952886e0c6d8503af4561df2ded391b8cd5476..1e4e63462744a9ad0e62153d18f7d53bfb04d5f8 100644 (file)
@@ -83,7 +83,7 @@ void init_trace_bufs(void)
         buf->head_ptr = buf->vdata;
         
         /* For use in user space. */
-        buf->data = (struct t_rec *)__pa(buf->vdata);
+        buf->data = __pa(buf->vdata);
         buf->head = 0;
 
         /* For use in both. */
@@ -92,7 +92,7 @@ void init_trace_bufs(void)
     }
 
     printk("Xen trace buffers: initialised\n");
+    
     wmb(); /* above must be visible before tb_init_done flag set */
 
     tb_init_done = 1;
@@ -102,7 +102,7 @@ void init_trace_bufs(void)
  * get_tb_info - get trace buffer details
  * @st: a pointer to a dom0_gettbufs_t to be filled out
  *
- * Called by the %DOM0_GETTBUFS dom0 op to fetch the physical address of the
+ * Called by the %DOM0_GETTBUFS dom0 op to fetch the machine address of the
  * trace buffers.
  */
 int get_tb_info(dom0_gettbufs_t *st)
@@ -111,14 +111,14 @@ int get_tb_info(dom0_gettbufs_t *st)
     {
         extern unsigned int opt_tbuf_size;
         
-        st->phys_addr = __pa(t_bufs[0]);
+        st->mach_addr = __pa(t_bufs[0]);
         st->size      = opt_tbuf_size * PAGE_SIZE;
         
         return 0;
     }
     else
     {
-        st->phys_addr = 0;
+        st->mach_addr = 0;
         st->size      = 0;
         return -ENODATA;
     }
index c7e51455d269206f252efaaf820b83452597b6f6..99d6509f3828594018af0b419e4820adc12a1b93 100644 (file)
@@ -19,7 +19,7 @@
  * This makes sure that old versions of dom0 tools will stop working in a
  * well-defined way (rather than crashing the machine, for instance).
  */
-#define DOM0_INTERFACE_VERSION   0xAAAA0014
+#define DOM0_INTERFACE_VERSION   0xAAAA0015
 
 #define MAX_DOMAIN_NAME    16
 
@@ -216,11 +216,11 @@ typedef struct {
     s32          cpu;                 /*  4: -1 implies unpin */
 } PACKED dom0_pincpudomain_t; /* 8 bytes */
 
-/* Get trace buffers physical base pointer */
+/* Get trace buffers machine base address */
 #define DOM0_GETTBUFS         21
 typedef struct {
     /* OUT variables */
-    memory_t phys_addr;   /*  0: location of the trace buffers       */
+    memory_t mach_addr;   /*  0: location of the trace buffers       */
     MEMORY_PADDING;
     u32      size;        /*  8: size of each trace buffer, in bytes */
 } PACKED dom0_gettbufs_t; /* 12 bytes */
index b5458b9f710ca0a04a9fce69538fb842231d66dd..52d53842ca10069058790b79a8ed2a506ec5b514 100644 (file)
@@ -17,13 +17,13 @@ struct t_rec {
  * field, indexes into an array of struct t_rec's.
  */
 struct t_buf {
-    struct t_rec *data;     /* pointer to data area.  physical address
-                             * for convenience in user space code            */
+    unsigned long data;      /* pointer to data area.  machine address
+                              * for convenience in user space code           */
 
     unsigned long size;      /* size of the data area, in t_recs             */
     unsigned long head;      /* array index of the most recent record        */
 
-    /* Kernel-private elements follow... */
+    /* Xen-private elements follow... */
     struct t_rec *head_ptr; /* pointer to the head record                    */
     struct t_rec *vdata;    /* virtual address pointer to data               */
 };